package my.algorithms.mcorrea.topcoder;

import java.util.HashSet;
import java.util.Set;

/**
 * http://community.topcoder.com/stat?c=problem_statement&pm=7850
 * @author mcorrea
 */
public class BestHotel {

    public static void main(String[] args) {
		int[] price ={100,200};
		int[] quality = {2,3};
		System.out.println( numberOfDisadvantageous(price, quality)  );
		
		int[] price2 ={100,200};
		int[] quality2 = {3,3};
		System.out.println( numberOfDisadvantageous(price2, quality2)  );
		
		int[] price3 ={100,200, 300};
		int[] quality3 = {5,4, 3};
		System.out.println( numberOfDisadvantageous(price3, quality3)  );
		
		int[] price4 ={200,300,100,500,100,100,200};
		int[] quality4 = {7,7,4,8,4,3,6};
		System.out.println( numberOfDisadvantageous(price4, quality4)  );
		
		
		
    }
	
	public static int numberOfDisadvantageous(int[] price, int[] quality){
	
			Set<Integer> disadv = new HashSet<Integer>();
			for(int i=0; i<price.length; i++){
				for(int j=0;j<price.length;j++){
					if(i!=j){
						if( (price[j]<=price[i] && quality[j]>=quality[i]) && (price[j]!=price[i] || quality[j]!=quality[i]) ){
							if(!disadv.contains(i)){
								disadv.add(i);
							}
						}
					}
				}
			
			}
			return disadv.size();
	}

}
